package com.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.mapper.OrderItemsMapper;
import com.shop.pojo.OrderItems;
import com.shop.service.OrderItemsService;
import com.shop.vo.OrderItemsQueryRequest;
import com.shop.vo.OrderItemsSaveRequest;
import com.shop.vo.OrderItemsUpdateRequest;
import org.springframework.beans.BeanUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;


@Service("orderItemsService")
public class OrderItemsServiceImpl extends ServiceImpl<OrderItemsMapper, OrderItems> implements OrderItemsService {

    @Override
    public IPage<OrderItems> page(Page page, OrderItemsQueryRequest request){
        QueryWrapper<OrderItems> wrapper = OrderItems.queryWrapper(request);
        return this.page(page,wrapper);
    }

    @Transactional
    @Override
    public void save(OrderItemsSaveRequest request){
        OrderItems orderItems = new OrderItems();
        BeanUtils.copyProperties(request,orderItems);
        this.save(orderItems);
    }

    @Transactional
    @Override
    public void update(OrderItemsUpdateRequest request){
        OrderItems orderItems = new OrderItems();
        BeanUtils.copyProperties(request,orderItems);
        this.updateById(orderItems);
    }

    @Transactional
    @Override
    public void delete(String id){
        UpdateWrapper<OrderItems> updateWrapper = new UpdateWrapper();
        this.update(updateWrapper);
    }

}